var t = getApp();

Page({
    data: {
        showBox: !1,
        recordsList: [],
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(t) {},
    onShow: function() {
        this.getData();
    },
    getData: function() {
        this.setData({
            page: 1
        });
        var a = this, e = t.getNetAddresss("plugin.yun-sign.frontend.h5.worker.get-list");
        wx.showLoading({
            title: "加载中",
            mask: !0
        }), t._getNetWork({
            url: e,
            data: {
                page: 1
            },
            success: function(t) {
                console.log(t), wx.hideLoading();
                var e = t.data;
                1 === e.result ? (a.setData({
                    dataInfo: e.data,
                    recordsList: e.data.data,
                    isLoadMore: !0,
                    total_page: e.data.last_page
                }), a.data.total_page || a.setData({
                    total_page: 0
                })) : wx.showModal({
                    content: e.msg,
                    showCancel: !1,
                    success: function(t) {
                        wx.navigateBack({
                            delta: 1
                        });
                    }
                });
            },
            fail: function(t) {
                wx.hideLoading(), console.log(t, "------失败-------");
            }
        });
    },
    getMoreData: function() {
        var a = this;
        if (this.data.isLoadMore) if (this.data.page >= this.data.total_page) this.setData({
            isLoadMore: !1
        }); else {
            this.setData({
                page: this.data.page + 1
            });
            var e = t.getNetAddresss("plugin.yun-sign.frontend.h5.worker.get-list");
            wx.showLoading({
                title: "加载中",
                mask: !0
            }), t._getNetWork({
                url: e,
                data: {
                    page: a.data.page
                },
                success: function(t) {
                    if (wx.hideLoading(), 1 === res.result) {
                        console.log(t);
                        var e = t.data.data.data, o = a.data.recordsList.concat(e);
                        a.setData({
                            isLoadMore: !0,
                            recordsList: o
                        });
                    } else a.setData({
                        page: a.data.page - 1,
                        isLoadMore: !1
                    });
                },
                fail: function(t) {
                    console.log(t, "-------失败 -----------"), a.setData({
                        isLoadMore: !0
                    }), wx.hideLoading();
                }
            });
        } else t.tips("没有更多了");
    },
    delRow: function(a) {
        var e = a.target.dataset.roleId, o = t.getNetAddresss("plugin.yun-sign.frontend.h5.worker.del-worker");
        t._getNetWork({
            url: o,
            data: {
                id: e
            },
            success: function(a) {
                1 === a.data.result ? (that.setData({
                    recordsList: []
                }), that.getData(), t.tips("删除成功!")) : t.tips("删除失败!");
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getcontentHeight: function() {
        var t = this, a = wx.createSelectorQuery();
        a.select("#btn").boundingClientRect();
        var e = 600;
        try {
            var o = wx.getSystemInfoSync();
            e = o.windowHeight;
        } catch (t) {
            console.log(t);
        }
        a.exec(function(a) {
            t.setData({
                contentHeight: e - a[0].height + "px"
            });
        });
    },
    toAdd: function() {
        wx.navigateTo({
            url: "/packageH/signPage/addStaff/addStaff"
        });
    },
    handleShowBox: function() {
        this.setData({
            showBox: !this.data.showBox
        });
    },
    onHide: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多数据");
    }
});